﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:odc="clr-namespace:Odyssey.Controls"
        xmlns:fx="clr-namespace:Odyssey.Effects" xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/Ribbon/DefaultRibbonButtonBrushes.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate x:Key="RibbonTextBoxTemplate" TargetType="{x:Type odc:RibbonTextBox}">
        <Grid Focusable="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Image RenderOptions.EdgeMode="Aliased" x:Name="img"
                    RenderOptions.BitmapScalingMode="{Binding Path=(odc:ImageRenderOptions.SmallImageScalingMode), RelativeSource={RelativeSource TemplatedParent}}"
                    Source="{TemplateBinding Image}" Width="16" Height="16" Grid.Column="0" Margin="2" VerticalAlignment="Center" HorizontalAlignment="Center"
                    Focusable="False" />
            <TextBlock x:Name="text" Text="{TemplateBinding Title}" VerticalAlignment="Center" Grid.Column="1" Margin="2,0,2,0" Focusable="False"
                    Width="{TemplateBinding LabelWidth}" />

            <Border Grid.Column="2" Margin="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" x:Name="outerBorder"
                    Width="{TemplateBinding ContentWidth}" HorizontalAlignment="Stretch" Focusable="False" BorderThickness="{TemplateBinding BorderThickness}"
                    Opacity="0.65" />
            <Border BorderBrush="White" BorderThickness="1" Focusable="False" Grid.Column="2" Margin="1" Background="Transparent" x:Name="innerBorder">
                <ScrollViewer x:Name="PART_ContentHost" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Image" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="img" Value="Collapsed" />
                <Setter Property="Margin" TargetName="img" Value="0" />
            </Trigger>
            <Trigger Property="Title" Value="">
                <Setter Property="Margin" TargetName="text" Value="0" />
            </Trigger>
            <Trigger Property="odc:RibbonBar.Size" Value="Small">
                <Setter Property="Visibility" Value="Collapsed" TargetName="text" />
            </Trigger>
            <Trigger Property="odc:RibbonBar.Size" Value="Minimized">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>

            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsEnabled" Value="False" />
                    <Condition Property="odc:RibbonChrome.IsGrayScaleEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Opacity" Value="{DynamicResource {ComponentResourceKey odc:Skins, DisabledImageOpacity}}" TargetName="img" />
                <Setter Property="RenderOptions.EdgeMode" Value="Unspecified" TargetName="img" />
                <Setter Property="RenderOptions.BitmapScalingMode" Value="Fant" TargetName="img" />
                <Setter Property="Effect" TargetName="img">
                    <Setter.Value>
                        <fx:GrayscaleEffect />
                    </Setter.Value>
                </Setter>
            </MultiTrigger>

            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="outerBorder" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" To="1" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="outerBorder" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" From="1" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="Opacity" Value="1.0" TargetName="outerBorder"/>
                <Setter Property="BitmapEffect" TargetName="outerBorder">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowSize="2" GlowColor="{DynamicResource {ComponentResourceKey odc:Skins, GlowColor}}" Opacity="1" />
                    </Setter.Value>
                </Setter>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey odc:Skins, DisabledForegroundBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>

    </ControlTemplate>

    <Style TargetType="{x:Type odc:RibbonTextBox}">
        <Setter Property="odc:KeyTip.YOffset" Value="4" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template" Value="{StaticResource RibbonTextBoxTemplate}" />
        <Setter Property="Background" Value="White" />
        <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, DefaultBorderBrush}}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="MinHeight" Value="24" />
        <Setter Property="Focusable" Value="True" />
    </Style>
</ResourceDictionary>